package com.sh.usercenterbackend.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Auther: sh
 * @Date: 2024/12/13 23:14
 * @Description:
 */
@Data
@NoArgsConstructor
public class BaseResponse<T> implements Serializable {
    private int code;  // 状态码  0-成功 其他值-失败（由具体错误决定）
    private T data;
    private String message;
    private String description;


    public BaseResponse(int code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public BaseResponse(int code, String message, String description) {
        this.code = code;
        this.description = description;
        this.message = message;
        this.data = null;
    }

    public BaseResponse(int code, T data, String message, String description) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description = description;
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(), null, errorCode.getMessage(), errorCode.getDescription());
    }

    public BaseResponse(int code, String description) {
        this.code = code;
        this.data = null;
        this.description = description;
    }
}

